package file;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-08-07
 * Time: 11:06
 */
//使用字符流读取文件
public class Demo07 {
    public static void main(String[] args) throws IOException {
        //1.打开文件
        Reader reader = new FileReader("./test1.txt");

        //2.读取文件 ( read方法与 字节流类似)
        char []bufffer = new char[1024];
        int len = reader.read(bufffer);
        for(int i=0; i<len; i++) {
            System.out.println(bufffer[i]);
        }

        //3.关闭文件
        reader.close();
    }

}
